<?

//当前类别
$this_type = 'et';



switch($type){
	case'add':		//添加
		
		//添加
		if($go=='insert'){
			$orderby	= (int)$orderby;
			$runmode	= (int)$runmode;
			$lists		= (int)$orderby;
			
			$titles = trim($titles);
			if(!$titles){
				$error=1;
				basic::flash('抱歉，请输入功能名称！');
			}
			
			if($error!=1){
				$db->query("INSERT INTO menus (
				titles,types,orderby,lists
				) VALUES(
				'$titles','$this_type','$orderby','$lists'
				)");
				
				
				basic::flash('恭喜，资料添加成功！',"sys.php?model=admin&action={$action}&type=add",3);
			}
		}
		
		$posturl   = "sys.php?model=admin&action={$action}&type=add&go=insert";
		
		$this_file = $action.'_mod';
	break;
	
	case'edit':		//编辑
		
		//更新
		if($go=='update'){
			$orderby	= (int)$orderby;
			$runmode	= (int)$runmode;
			$lists		= (int)$lists;
			$tid		= (int)$tid;
			
			$titles = trim($titles);
			if(!$titles){
				$error=1;
				basic::flash('抱歉，请输入功能名称！');
			}
			
			if($error!=1){
				$db->query("UPDATE menus SET titles='$titles',orderby='$orderby',lists='$lists' WHERE types='$this_type' AND meid='$id'");
				
				basic::flash('恭喜，资料修改成功！',"sys.php?model=admin&action={$action}&type=edit&id=".$id,3);
			}
		}
		
		$mod = $db->rows("SELECT * FROM menus WHERE meid='$id'");
		
		$posturl   = "sys.php?model=admin&action={$action}&id={$id}&type=edit&go=update";
		
		//标识状态
		$lscheck   = ($mod['lists']==1)?'checked':'';
		
		$this_file = $action.'_mod';
	break;
	
	case'del':		//删除
		
		$db->query("DELETE FROM menus WHERE types='$this_type' AND meid='$id'");
		
		basic::flash('恭喜，资料删除成功！',"sys.php?model=admin&action={$action}",3);
	break;
	
	
	default:
		$tid = (int)$tid;
		
		//排序处理
		if(($type=='up' || $type=='down') && $meid){
			echo 1;
			order(array(
				'table'=>'menus',
				'name'=>'orderby',
				'modes'=>$type,
				'where'=>'tid='.$tid,
				'idname'=>'meid',
				'id'=>$meid,
				'order'=>' ORDER BY orderby ASC,meid ASC',
			));
		}
		
		if($tid>0){
			$where = " AND tid='$tid' ";
		}else{
			$where = "";
		}
		
		$info = $db->limit("SELECT * FROM menus WHERE types='$this_type' $where ORDER BY orderby ASC,meid ASC",$page,20);
		$pager = $info['info'];
		$data_list = $info['query'];
		$pages = multi($pager['nums'],$pager['limit'],$pager['nowpage'],$pager['pages']);
		
		
		$this_file = $action;
}

Basic :: setModelFile('head');
Basic :: setModelFile($this_file);
Basic :: setModelFile('bottom');
$tpl->p($this_file);

?>